﻿Chenxin.UI.BargainStat = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/BargainStat.ashx',
    createSearch: function() {
        return new Chenxin.UI.BargainStatSearch({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.GroupReportGrid({
            actionUrl: this.actionUrl + '?op=getlist',
            id: 'search_table',
            renderTo: 'search_table',
            hasCheckBox: false,
            modelId: 'departid',
            sortType: 'local',
            autoLoad: false,
            cellBorder: true,
            height:400,
            scope: this,
			title:'成交统计表',
			rowGroupSetting:[
				{field:'business',head:'商圈',width:120,autoCount:true},
				{field:'departname',head:'门店',width:120,autoCount:true}
			],
            columns: {
				a:{
					head:'买卖',
					items:{
						a_count: {
							head: '业绩',
							width: 120,
							sortable:true
						},
						a_sum: {
							head: '合同数',
							width: 80,
							sortable:true
						},
						a_point: {
							head: '点数',
							width: 80,
							sortable:true
						}
					}
				},
				b:{
					head:'租赁',
					items:{
						b_count: {
							head: '业绩',
							width: 120,
							sortable:true
						},
						b_sum: {
							head: '合同数',
							width: 80,
							sortable:true
						},
						b_point: {
							head: '点数',
							width: 80,
							sortable:true
						}
					}
				},
                totil: {
                    head: '业绩小计',
                    width: 120,
					sortable:true
                },
				c:{
					head:'零散业务',
					items:{
						c_count: {
							head: '业绩',
							width: 120,
							sortable:true
						},
						c_sum: {
							head: '合同数',
							width: 80,
							sortable:true
						},
						c_point: {
							head: '点数',
							width: 80,
							sortable:true
						}
					}
				},
				d:{
					head:'其他业务',
					items:{
						d_count: {
							head: '业绩',
							width: 120,
							sortable:true
						},
						d_sum: {
							head: '合同数',
							width: 80,
							sortable:true
						},
						d_point: {
							head: '点数',
							width: 80,
							sortable:true
						}
					}
				},
				e: {
				    head: '联动业务',
				    items: {
				        e_count: {
				            head: '业绩',
				            width: 120,
				            sortable: true
				        },
				        e_sum: {
				            head: '合同数',
				            width: 80,
				            sortable: true
				        },
				        e_point: {
				            head: '点数',
				            width: 80,
				            sortable: true
				        }
				    }
				},
                all_totil: {
                    head: '业绩合计',
                    width: 120,
					sortable:true
                }
            }
        });
    },
    initEvent: function() {
        var _this = this;
    },
    initComponent: function() {
        Chenxin.UI.BargainStat.superclass.initComponent.call(this);
    }
});

/**
*查询面板
*/
Chenxin.UI.BargainStatSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'search',
    initEvent: function() {
        var _this = this;

        //查询按钮
        $('#btn_search').click(function() {
            _this.scope.reloadGrid();
        });

        var curdate = new Date();
        $('#starttime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 1) + '-1');
        if (curdate.getMonth() + 1 == 12)
            $('#eTime').val(curdate.getFullYear() + 1 + '-1-1');
        else
            $('#eTime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 2) + '-1');
    },
    createComboList: function() {
        var combl = new Chenxin.UI.StructComboList({
            tbxWidth: 65
        });
        var structs = combl.comboList;
        return structs;
    },
    initComponent: function() {
        Chenxin.UI.BargainStatSearch.superclass.initComponent.call(this);
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(document).ready(function() {
    var BargainStat = new Chenxin.UI.BargainStat();
});